/*
 GET https://github.com/login/oauth/authorize
 Client ID: Iv1.f7197e46cd738440
 App ID: 77935
  https://github.com/login/oauth/authorize?
  client_id=Iv1.f7197e46cd738440
  &redirect_url=http://localhost:3000/
  &scope=users
  &state=123

 */

 let code = "adb27258d4493a65607c"
 let state = "123"
 let client_secret = "043d5627feaf3e8bf4a18f5101a86b7c5848ea34"
 let client_id = "Iv1.f7197e46cd738440"
 let redirect_url = encodeURIComponent("http://localhost:3000/")


 let xhr = new XMLHttpRequest;
let params = `code=${code}&state=${state}&client_secret=${client_secret}&client_id=${client_id}&redirect_url=${redirect_url}`
 xhr.open("POST",`https://github.com/login/oauth/access_token?${params}`, true)
 xhr.send(null)

 xhr.addEventListener("readystatechange",function(event){
     if(xhr.readyState === 4) {

     }
 })

 /* 
  获取github用户信息
 */



let xhr = new XMLHttpRequest;
xhr.open("GET",`https://api.github.com/user`, true)
xhr.setRequestHeader("Authorization","token cf6a04054121eaad19830fdb5163974de88a7ecc")
xhr.send(null)

xhr.addEventListener("readystatechange",function(event){
    if(xhr.readyState === 4) {

    }
})